# -*- coding: utf-8 -*-
"""
Created on Thu Feb  1 20:05:33 2024

@author: zzc
"""

import os
import pandas as pd

# 指定包含CSV文件的文件夹路径
folder_path = 'C:/Users/zzc/Desktop/FIRstat/FIR_csv/'

# 获取文件夹中所有CSV文件的文件名
csv_files = [f for f in os.listdir(folder_path) if f.endswith('.csv')]
#print(csv_files)
# 遍历每个CSV文件
for csv_file in csv_files:
    file_path = os.path.join(folder_path, csv_file)

    # 读取CSV文件为DataFrame
    df = pd.read_csv(file_path, delimiter=',')
   # print(df)
    # 计算fiveprime和threeprime的平均值
    avg_fiveprime = df['fiveprime'].mean()
    avg_threeprime = df['threeprime'].mean()

    # 输出结果
    output_str = f"{csv_file}\t{avg_fiveprime}\t{avg_threeprime}"

    # 打印结果
    print(output_str)

    # 如果需要保存结果到文件
    # with open('output.txt', 'a') as output_file:
    #     output_file.write(output_str + '\n')
